package com.d3works.apps.supplychain.service;

import com.d3works.apps.base.db.Company;
import com.d3works.apps.base.db.Currency;
import com.d3works.apps.base.db.Partner;
import com.d3works.apps.base.db.PriceList;
import com.d3works.apps.base.db.Product;
import com.d3works.apps.base.db.TradingName;
import com.d3works.apps.purchase.db.PurchaseOrder;
import com.d3works.apps.purchase.db.PurchaseOrderLine;
import com.d3works.apps.stock.db.StockLocation;
import com.d3works.auth.db.User;
import com.d3works.exception.D3worksException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

public interface PurchaseOrderSupplychainService {

  void updateToValidatedStatus(PurchaseOrder purchaseOrder) throws D3worksException;

  void generateBudgetDistribution(PurchaseOrder purchaseOrder);

  PurchaseOrder createPurchaseOrder(
      User buyerUser,
      Company company,
      Partner contactPartner,
      Currency currency,
      LocalDate deliveryDate,
      String internalReference,
      String externalReference,
      StockLocation stockLocation,
      LocalDate orderDate,
      PriceList priceList,
      Partner supplierPartner,
      TradingName tradingName)
      throws D3worksException;

  PurchaseOrder mergePurchaseOrders(
      List<PurchaseOrder> purchaseOrderList,
      Currency currency,
      Partner supplierPartner,
      Company company,
      StockLocation stockLocation,
      Partner contactPartner,
      PriceList priceList,
      TradingName tradingName)
      throws D3worksException;

  void updateAmountToBeSpreadOverTheTimetable(PurchaseOrder purchaseOrder);

  void applyToallBudgetDistribution(PurchaseOrder purchaseOrder);

  void setPurchaseOrderLineBudget(PurchaseOrder purchaseOrder);

  String createShipmentCostLine(PurchaseOrder purchaseOrder) throws D3worksException;

  PurchaseOrderLine createShippingCostLine(PurchaseOrder purchaseOrder, Product shippingCostProduct)
      throws D3worksException;

  boolean alreadyHasShippingCostLine(PurchaseOrder purchaseOrder, Product shippingCostProduct);

  String removeShipmentCostLine(PurchaseOrder purchaseOrder);

  BigDecimal computeExTaxTotalWithoutShippingLines(PurchaseOrder purchaseOrder);

  void updateBudgetDistributionAmountAvailable(PurchaseOrder purchaseOrder);
}
